#include "cdDispose.h"

void cdDispose(int netfd,MYSQL * mysql,char * username,char * prev_path){
    char sql[1024] = {0};
    sprintf(sql,"select * from usrfile where username = '%s' and path = '%s' ;",username,prev_path);
    int qret = mysql_query(mysql,sql);
    if(qret != 0){
        fprintf(stderr,"mysql_query :%s\n",mysql_error(mysql));
        send(netfd,"0",1,MSG_NOSIGNAL); 
        return ;
    }
    MYSQL_RES * table = mysql_store_result(mysql);
    
    if(mysql_num_rows(table) == 0){
        send(netfd,"0",1,MSG_NOSIGNAL);
        return ;
    }

    MYSQL_ROW row = mysql_fetch_row(table);
    
    if( strcmp(row[5],"d") == 0){
        send(netfd,"1",1,MSG_NOSIGNAL);
    }else{
        send(netfd,"0",1,MSG_NOSIGNAL);
    } 
    return ;
}


